home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / X_TREE.DMO < prev    next >
Text File  |  1996-07-04  |  3KB  |  65 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   X_TREE  .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $STACK  2048                    ' a recursive function exists, need room
  22. $STRING 4                       ' lots'a strings in here too
  23. $INCLUDE "DAS-NB01.INC"         ' yup! need'em both
  24. $INCLUDE "DAS-NB02.INC"         '
  25. COLOR 7, 0
  26. CLS
  27.  
  28. ? "┌──────────────────────────────────────────────────────────────────────────
  29. ? "│ fTREElist% ( Tree$(), Indent%, MaxCols%, Drive$ )
  30. ? "│ fTREEpath$ ( Tree$(), ItemNo% )
  31. ? "│ fTREEfind% ( Tree$(), Path$   )
  32. ? "├──────────────────────────────────────────────────────────────────────────
  33. ? "│ fTREElist% does for directories what fDIRlist% does for files! It creates
  34. ? "│ a working list of directories & sub-dirs that can be used in a menu to
  35. ? "│ to allow the user to select the path he/she wishes to work with.
  36. ? "│ fTREEpath$ returns the full drive:\path\ for a given item of Tree$()
  37. ? "│ fTREEfind% returns the item# for the matching Tree$() element
  38. ? "└──────────────────────────────────────────────────────────────────────────
  39.  
  40. Drive$   = "C"                      ' change this to match your disk
  41. Indent%  =  2                       ' the number of cols indent each level
  42. MaxCols% = 30                       ' max column width for display items
  43. CDir$    = fCurDir$( Drive$ )       ' or whatever you want
  44.  
  45. UBnd% = 10                          ' this shouldn't be enough!
  46. DO
  47.   REDIM Tree$(UBnd%)
  48.   LastDir% = fTREElist%( Tree$(), Indent%, MaxCols%, Drive$ )
  49.   IF LastDir% =< Ubnd% THEN EXIT LOOP
  50.   UBnd% = LastDir%
  51. LOOP
  52.  
  53. Item% = fTREEfind%( Tree$(), CDir$ )         ' locate it's pos in Tree$()
  54.  
  55. FOR X% = 1 TO LastDir%
  56.   IF X% = Item% THEN COLOR 0, 7              ' ugly but it works!
  57.   PRINT MID$( Tree$(X%), 3 )                 ' NOTE the MID$ printing
  58.   IF X% = Item% THEN COLOR 7, 0
  59.   IF ( X% MOD 10 ) = 0 THEN fAnyKey          ' pause for the human
  60. NEXT
  61.  
  62. Item% = MIN( 17, LastDir% )                  ' pick a number if you will
  63. PRINT USING "ITEM ##'s FULL PATH: "; Item%;
  64. PRINT fTREEpath$( Tree$(), Item% )
  65.